package anylise;

import configMeta.ConfigFolderListMeta;
import utils.FileUtils;

import java.io.File;

/**
 * Created by eran on 14-9-7.
 */
public class TypeInfoTreeAnalyzer extends ScanFolderAnalyzerBasic
{
    private static String[] TYPES = {"GUI", "InfoTree"};

    @Override
    public void analysisFolder(ConfigFolderListMeta _folderMeta)
    {
        File folderFile = new File(_folderMeta.path);
        if (folderFile.isDirectory())
        {
            for (File subFile : folderFile.listFiles())
            {
                String fileName = FileUtils.getFileNameNoEx(subFile.getName());

                //InfoTree目录下生成的文件为
                //xxx.ce --->对应的Meta文件
                //xxx_01.png/xxx_01.atals  --->对应的纹理名及PNG图片名
                //所以QueueName用xxx表示
                String queueName;

                //判断当前名字是否为xxx_01这样的组合,如果是则仅取下划线前面的部分
                //如果不是则认为是xxx.ce文件 则直接用该名字作为文件名
                //注意!! InforTree模式默认兼容Single模式,只不过是在上面做了一个扩展


                if (fileName.lastIndexOf("_") >= 0)
                {
                    queueName = fileName.substring(0, fileName.lastIndexOf("_"));
                } else
                {
                    queueName = fileName;
                }
                tryToPackCurrentFile(subFile, queueName, _folderMeta.releasePath);
            }
        } else
        {
            System.err.println("File : " + folderFile.getAbsolutePath() + "  is not an folder");
        }
    }

    @Override
    protected String[] getInterestedFolderTypeArray()
    {
        return TYPES;
    }
}
